<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>事件修饰符</title>
</head>
<body>

<!--
  .stop 阻止冒泡
  .prevent 阻止默认行为
-->

<div id="app">

  <div @click="parentClick" style="width: 100px; height: 100px; border: 1px solid red">
    <button @click="childClick">子按钮</button>
  </div>

  <hr>

  <div @click="parentClick" style="width: 100px; height: 100px; border: 1px solid red">
    <button @click.stop="childClick">子按钮</button>
  </div>

  <hr>
  <div>
    <a href="http://www.baidu.com" @click="baidu">百度一下</a>
  </div>
  <div>
    <a href="http://www.baidu.com" @click.prevent="baidu1">百度一下(阻止默认行为)</a>
  </div>
</div>

<script src="../lib/vue.js"></script>
<script>
  let vm = new Vue({
    el: '#app',
    data: {
      msg: 'Hello World'
    },
    methods: {
      childClick() {
        console.log('我是子元素')
      },
      parentClick() {
        console.log('我是父元素')
      },
      baidu() {
        console.log('跳转到百度')
      },
      baidu1() {
        console.log('阻止跳转到百度')
      }
    }
  })
</script>

</body>
</html>